package com.szpx.service.impl;

 

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.szpx.entity.HZJ.Course;
import com.szpx.mapper.CourseMapper;
import com.szpx.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public PageInfo<Course> getCoursesByPage(int pageNum, int pageSize, Map<String, Object> params) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> courses = courseMapper.findByCondition(params);
        return new PageInfo<>(courses);
    }

    @Override
    public Course getCourseById(Long id) {
        return courseMapper.findById(id);
    }

    @Override
    public boolean createCourse(Course course) {
        return courseMapper.insert(course) > 0;
    }

    @Override
    public boolean updateCourse(Course course) {
        return courseMapper.update(course) > 0;
    }

    @Override
    public boolean deleteCourse(Long id) {
        return courseMapper.deleteById(id) > 0;
    }
}
